#include "StdAfx.h"
#include "ProcessorInformation.h"

using namespace System;
using namespace Adaptive::Foundation;
using namespace Adaptive::Win32;

/*--------------------------------------------------------------------------------
 * Constructor / Dispose / Destructor Methods
 *------------------------------------------------------------------------------*/
#pragma region Constructor / Dispose / Destructor Methods
// <summary>
// Initializes a new instance of the class.
// </summary>
// <remarks>
// This is the default constructor.
// </remarks>
ProcessorInformation::ProcessorInformation()
{
	SYSTEM_INFO* data = NULL;

	data = new SYSTEM_INFO();
	::GetSystemInfo(data);

	_architecture = (ProcessorArchitecture)data->wProcessorArchitecture;
	_pageSize = data->dwPageSize;
	_minAddress = IntPtr::IntPtr( data->lpMinimumApplicationAddress );
	_maxAddress = IntPtr::IntPtr( data->lpMaximumApplicationAddress );
	_processorMask = data->dwActiveProcessorMask;
	_processorCount = data->dwNumberOfProcessors;
	_processorType = (ProcessorType) data->dwProcessorType;
	_processorLevel = data->wProcessorLevel;
	_processorRevision = data->wProcessorRevision;

}
// <summary>
// Class destructor.
// </summary>
ProcessorInformation::~ProcessorInformation()
{
	_minAddress = IntPtr::Zero;
	_maxAddress = IntPtr::Zero;
}
#pragma endregion

/*--------------------------------------------------------------------------------
 * Public Properties
 *------------------------------------------------------------------------------*/
#pragma region Public Properties
// <summary>
// Gets the architecture of the system's processor(s).
// </summary>
// <value>
// A <see cref="ProcessorArchitecture"/> enumeration indicating the architecture type.
// </value>
ProcessorArchitecture ProcessorInformation::Architecture::get()
{
    return _architecture;
}
// <summary>
// Gets the page size for the processor.
// </summary>
// <value>
// The page size and the granularity of page protection and commitment.
// </value>
int ProcessorInformation::PageSize::get()
{
	return _pageSize;
}
// <summary>
// Gets the pointer to the lowest memory address accessible to applications and dynamic-link libraries. 
// </summary>
// <value>
// An <see cref="IntPtr"/> value containing the pointer value (memory address).
// </value>
IntPtr ProcessorInformation::MinAddress::get()
{
	return _minAddress;
}
// <summary>
// Gets the pointer to the highest memory address accessible to applications and dynamic-link libraries. 
// </summary>
// <value>
// An <see cref="IntPtr"/> value containing the pointer value (memory address).
// </value>
IntPtr ProcessorInformation::MaxAddress::get()
{
	return _maxAddress;
}
// <summary>
// Gets the active processor mask representing the set of processors configured into the system.
// </summary>
// <value>
// An integer value containing the bit flags; Bit 0 is processor 0; bit 31 is processor 31.
// </value>
int ProcessorInformation::ProcessorMask::get()
{
	return _processorMask;
}
// <summary>
// Gets the number of processors in the system.
// </summary>
// <value>
// Number of processors in the system.
// </value>
int ProcessorInformation::ProcessorCount::get()
{
	return _processorCount;
}
// <summary>
// Gets the processor type.
// </summary>
// <value>
// A <see cref="ProcessorType"/> enumerated value.
// </value>
ProcessorType ProcessorInformation::TypeOfProcessor::get()
{
	return _processorType;
}
// <summary>
// Gets the system's architecture-dependent processor level.
// </summary>
// <value>
// The processor level value for display purposes.
// </value>
int ProcessorInformation::ProcessorLevel::get()
{
	return _processorLevel;
}
// <summary>
// Gets the architecture-dependent processor revision.
// </summary>
// <value>
// A processor revision value.  Interpreting the value is based on the individual 
// processor architecture.  See the <see cref="SYSTEM_INFO"/> structure for more
// details.
// </value>
int ProcessorInformation::ProcessorRevision::get()
{
	return _processorRevision;
}
#pragma endregion

